home *** CD-ROM | disk | FTP | other *** search
- #include <OpenTransport.h> // open transport files
- #include <OpenTptLinks.h>
-
- OSStatus DoNegotiateRawModeOption(EndpointRef ep, UInt32 rawModeOption);
-
- // important note - use the options as defined in the OpenTptLinks.h header
- // when setting the rawModeOption parameter.
- OSStatus DoNegotiateRawModeOption(EndpointRef ep, UInt32 rawModeOption)
-
- {
- UInt8 buf[kOTFourByteOptionSize]; // define buffer for fourByte Option size
- TOption* opt; // option ptr to make items easier to access
- TOptMgmt req;
- TOptMgmt ret;
- OSStatus err;
- Boolean isAsync = false;
-
- opt = (TOption*)buf; // set option ptr to buffer
- req.opt.buf = buf;
- req.opt.len = sizeof(buf);
- req.flags = T_NEGOTIATE; // negotiate for rawmode option
-
- ret.opt.buf = buf;
- ret.opt.maxlen = kOTFourByteOptionSize;
-
-
- opt->level = LNK_TPI; // dealing with tpi
- opt->name = OPT_SETRAWMODE;
- opt->len = kOTFourByteOptionSize;
- opt->status = 0;
- *(UInt32*)opt->value = rawModeOption; // set the desired option level, true or false
-
- if (OTIsSynchronous(ep) == false) // check whether ep sync or not
- {
- isAsync = true; // set flag if async
- OTSetSynchronous(ep); // set endpoint to sync
- }
-
- err = OTOptionManagement(ep, &req, &ret);
-
- if (isAsync == true) // restore ep state if necessary
- OTSetAsynchronous(ep);
-
- // if no error then return the option status value
- if (err == kOTNoError)
- {
- if (opt->status != T_SUCCESS)
- err = opt->status;
- else
- err = kOTNoError;
- }
-
- return err;
- }
-